import 'package:flutter/material.dart';
import 'package:flutter_shop_z/config/service_url.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

//店家信息
class ShopInfoImg extends StatelessWidget {
  final String shopInfoImgUrl;
  final String shopInfoPhone;
  ShopInfoImg({this.shopInfoImgUrl, this.shopInfoPhone});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: ScreenUtil().setHeight(200),
      width: ScreenUtil().setWidth(750),
      child: InkWell(
          onTap: _cellPhone,
          child: Image.network("${serviceUrl}${shopInfoImgUrl}",
              fit: BoxFit.fill)),
    );
  }

  void _cellPhone() async {
    String url = 'tel:' + shopInfoPhone;
    //如果是打电话就可以直接使用,如果使用canLaunch(url)就取相反值，!await canLaunch(url)
    await launch(url);
    // String url = 'http://www.baidu.com';
    // if (await canLaunch(url)) {
    //   await launch(url);
    // } else {
    //   throw '>>>>>>没有此电话 ${url}';
    // }
  }
}
